import { Logger } from '@nestjs/common'
import { NestFactory } from '@nestjs/core'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { Log4jsLogger } from '@nestx-log4js/core'
import { AppModule } from './app.module'

const listenPort = 3000
const logger = new Logger('main.ts')

const  bootstrap = async () => {
  const app = await NestFactory.create(AppModule)

  const options = new DocumentBuilder()
    .setTitle('项目管理平台')
    .setDescription('xxx平台接口文档')
    .setVersion('1.0')
    .addBearerAuth({type: 'http', scheme: 'bearer', bearerFormat: 'JWT'}, 'jwt')
    // .addTag('cats')
    .build()
  const document = SwaggerModule.createDocument(app, options)
  SwaggerModule.setup('swagger-ui', app, document)

  app.useLogger(app.get(Log4jsLogger))
  app.enableCors()

  await app.listen(listenPort)
}
bootstrap().then(()=>{
  logger.log(`listen in http://localhost:${listenPort}`)
})
